<template>
	<view>
		<present :present="presentData"></present>
		<swiperTabber :tabar="tabBars" :tabIndex="tabIndex" :tabberStyle="{'border-bottom':'none'}"
		 @tabtap="ontabtap" :tabbarItemStyle="{'width':'40%','text-align':'center'}"
		  >
		</swiperTabber>
		 <view>
				<block v-for="(lib,index) in followlist" :key="index"  @scrolltolower="loadMore">
					<template v-if="tabIndex==index">
						<!-- 列表页 -->
						<block v-for="(item,index1) in lib.dataList" :key="index1">
							<commonList :item="item"></commonList>
						</block>
						<!-- 上拉加载 -->
						<loadMore :loadtext="lib.loadtext" ></loadMore>
					</template>
				</block>
		  </view>
	</view>
</template>

<script>
	import present from '../../components/common/present.vue';
	import swiperTabber from '../../components/index/swiper-tabbar.vue';
	import commonList from '../../components/common/common-list.vue';
	import loadMore from '../../components/common/load-more.vue';
	export default {
		components: {
			present,
			swiperTabber,
			commonList,
			loadMore
		},
		//下拉刷新
		onPullDownRefresh(){
			this.getData()
		},
		////上拉加载
		onReachBottom(){
			this.loadMore()
		},
		data(){
			return{
				presentData:{
					titlePic: '../../static/img/topicpic/14.jpeg',
					title: '一言不合就想打卡',
					desc: '甘于平凡，不甘平庸',
					total: '220',
					nowtatal: '555'
				},
				tabIndex: 0,
				tabBars: [{
					name: '默认',
					id: 'default'
				}, {
					name: '最新',
					id: 'nows'
				}],
				followlist: [{
					loadtext: '上拉加载更多',
					dataList: [
						{
							userheadpic: '../../static/img/userpic/11.jpg',
							userhead: '扯淡的你',
							sex: 0, //0男
							userage: '15',
							isfollow: false,
							usertext: '花想一双月相容onLaunch	当uni-app 初始化完成时触发（全局只触发一次）',
							userType: '0', //0img 1 video2发布，
							userPic: '../../static/img/datapic/14.jpg',
							useraddress: '北京 门头沟',
							userinfo: {
								forward: 20,
								news: 35,
								fabulous: 2222
							}
						},
						{
							userheadpic: '../../static/img/userpic/13.jpg',
							userhead: '小甜甜',
							sex: 1,
							userage: '15',
							isfollow: false,
							usertext: '花想一双月相容onLaunch	当uni-app 初始化完成时触发（全局只触发一次）',
							userType: '1', //0img 1 video2发布，
							userPic: '../../static/img/datapic/15.jpg',
							userPlayNum: '20w',
							userplayLong: '2:45',
							useraddress: '北京 门头沟',
							userinfo: {
								forward: 20,
								news: 35,
								fabulous: 2222
							}
						},
						{
							userheadpic: '../../static/img/userpic/16.jpg',
							sex: 1,
							userhead: '扯淡的你',
							userage: '15',
							isfollow: true,
							usertext: '花想一双月相容onLaunch	当uni-app 初始化完成时触发（全局只触发一次）',
							userType: '3', //0img 1 video2发布，
							userPic: '../../static/img/datapic/17.jpg',
							userPlayNum: '20w',
							userplayLong: '2:45',
							useraddress: '北京 门头沟',
							usertype3: {
								img: '../../static/img/datapic/20.jpg',
								text: '我喜欢你正如你爱上了她'
							},
							userinfo: {
								forward: 20,
								news: 35,
								fabulous: 2222
							}
						}
					]
				},
				{
					loadtext: '上拉加载更多',
					dataList: [
						{
							userheadpic: '../../static/img/userpic/11.jpg',
							userhead: '扯淡的你',
							sex: 0, //0男
							userage: '15',
							isfollow: false,
							usertext: '花想一双月相容onLaunch	当uni-app 初始化完成时触发（全局只触发一次）',
							userType: '0', //0img 1 video2发布，
							userPic: '../../static/img/datapic/14.jpg',
							useraddress: '北京 门头沟',
							userinfo: {
								forward: 20,
								news: 35,
								fabulous: 2222
							}
						},
						{
							userheadpic: '../../static/img/userpic/1.jpg',
							sex: 1,
							userhead: '扯淡的你',
							userage: '15',
							isfollow: true,
							usertext: '花想一双月相容',
							userType: '3', //0img 1 video2发布，
							userPic: '../../static/img/datapic/15.jpg',
							userPlayNum: '20w',
							userplayLong: '2:45',
							useraddress: '北京 门头沟',
							usertype3: {
								img: '../../static/img/datapic/24.jpg',
								text: '我喜欢你正如你爱上了她'
							},
							userinfo: {
								forward: 20,
								news: 35,
								fabulous: 2222
							}
						}
						]
				}]
			}
		},
		methods:{
			ontabtap(index) {
				this.tabIndex = index;
			},
			getData(){
				setTimeout(()=>{
					let obj={
							userheadpic: '../../static/img/userpic/16.jpg',
							userhead: '小甜甜',
							sex: 1,
							userage: '15',
							isfollow: false,
							usertext: '花想',
							userType: '1', //0img 1 video2发布，
							userPic: '../../static/img/datapic/18.jpg',
							userPlayNum: '20w',
							userplayLong: '2:45',
							useraddress: '北京 门头沟',
							userinfo: {
								forward: 20,
								news: 35,
								fabulous: 2222
							}
						}
					console.log(this.tabIndex)
					this.followlist[0].dataList.unshift(obj)
					uni.stopPullDownRefresh();
				},2000)
			},
			loadMore() {
				if(this.followlist[this.tabIndex].loadtext!="上拉加载更多"){return}
				//修改状态
				this.followlist[this.tabIndex].loadtext="加载中...";
				setTimeout(()=>{
					//获取完成
					let obj={
							userheadpic: '../../static/img/userpic/11.jpg',
							userhead: '扯淡的你',
							sex: 0, //0男
							userage: '15',
							isfollow: false,
							usertext: '花想一双月相容onLaunch	当uni-app 初始化完成时触发（全局只触发一次）',
							userType: '0', //0img 1 video2发布，
							userPic: '../../static/img/datapic/14.jpg',
							useraddress: '北京 门头沟',
							userinfo: {
								forward: 20,
								news: 35,
								fabulous: 2222
							},
						}
					this.followlist[this.tabIndex].dataList.push(obj);
					this.followlist[this.tabIndex].loadtext="上拉加载更多"
				},1000)
				// this.followlist[index].loadtext="我也是有底线的"
			}
		}
	}
</script>

<style lang="scss" scoped>
	
</style>
